package com.lagou.demo.rpc;

import com.lagou.demo.api.UserServiceApi;
import com.lagou.demo.pojo.User;
import com.lagou.demo.service.IUserService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class UserServiceApiImpl implements UserServiceApi {

    @Autowired
    private IUserService userService;

    @Override
    public String info(String token) {
        String email = null;
        User user = new User();
        user.setToken(token);
        try {
            User one = userService.findOne(user);
            if (one != null) {
                email = one.getEmail();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return email;
    }
}
